package com.eastfair.saga.proxy.impl;

import com.eastfair.core.context.ContextUtil;
import com.eastfair.saga.proxy.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.naming.Context;

@Component
@Slf4j
public class OrderServiceImpl implements OrderService {

    /**
     * 订单数量
     */
    public static Integer orderNum = 100;


    @Override
    public Boolean createOrder(Long orderId, Long userId, Long productId, Integer amount, Integer count) throws Exception {
        orderNum = orderNum + 1;
        log.info(ContextUtil.getProjectId()+" :::开始创建订单：：" + orderId+",订单数量："+ orderNum);
        return true;
    }

    @Override
    public Boolean revokeOrder(Long orderId) throws Exception {
        orderNum = orderNum - 1;
        log.info(ContextUtil.getProjectId()+" :::开始回滚订单：：" + orderId+",订单数量："+ orderNum);
        return true;
    }
}
